<!--suppress ALL-->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>曼巴oauth2.0权限中心</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Font Awesome -->

  <link rel="stylesheet" href="http://img.mabach.cn/index.css">
  <link  rel="stylesheet" href="http://img.mabach.cn/adminlte.min.css">



</head>
<body class="hold-transition login-page">
<div class="login-box" id="app">
  <div class="login-logo">
    <a href="#">曼巴oauth2.0权限中心</a>
  </div>
  <!-- /.login-logo -->
  <div class="card">
    <div class="card-body login-card-body">
      <p class="login-box-msg">请登录</p>
<!--      /api-oauth/toLogin/mobile-->
<!--      <el-button @click="login()" type="text">文字按钮</el-button>-->
      <a   :href="tomobile" style="float:right;font-size: 16px;">
        <i class="fa fa-envelope mr-1"></i>使用短信验证登录

      </a>
      <form >
        <div class="input-group mb-3">
          <input name="username" v-model="username" type="text" class="form-control" placeholder="用户名">
          <div class="input-group-append">
            <div class="input-group-text">
              <span class="fa fa-user"></span>
            </div>
          </div>
        </div>
        <div class="input-group mb-3">
          <input name="password" v-model="password" type="password" class="form-control" placeholder="密码">
          <div class="input-group-append">
            <div class="input-group-text">
              <span class="fas fa-lock"></span>
            </div>
          </div>
        </div>



        <div class="row mb-2 ">
          <div class="col-6">
              <input name="code" v-model="code"  type="text" class="form-control" placeholder="验证码">
          </div>
          <div class="col-6">
            <img onclick="this.src='/api-oauth/code/image?'+Math.random()" src="/api-oauth/code/image" alt="验证码"   />
          </div>
        </div>
        <!-- 提示信息, 表达式红线没关系，忽略它 -->
        <div th:if="${param.error}" >
          <span th:text="${session.SPRING_SECURITY_LAST_EXCEPTION?.message}" style="color:red"></span>
        </div>

        <div class="row">
          <div class="col-6">
              <div class="icheck-primary">
                <input name="remember-me" type="checkbox" id="remember">
                <label for="remember">
                  记住我
                </label>
            </div>
          </div>
          <!-- /.col -->
          <div class="col-6">
            <button type="button"  @click="login()" class="btn btn-primary btn-block">登录</button>

          </div>

          <!-- /.col -->
        </div>

      </form>



      <div class="social-auth-links text-center mb-3">



          <a :href="toQQLogin" class="btn btn-block btn-success">
           QQ登录
        </a>
      </div>



      <p class="mb-0">
        <a :href="toregister" class="text-center">注册帐号</a>
      </p>
    </div>
    <!-- /.login-card-body -->
  </div>
</div>
<!-- /.login-box -->

<!-- jQuery -->
<script  src="http://img.mabach.cn/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script  src="http://img.mabach.cn/bootstrap.bundle.min.js"></script>

<!-- import Vue before Element -->
<script src="http://img.mabach.cn/vue.js"></script>
<!-- import JavaScript -->
<script src="http://img.mabach.cn/elementui.js"></script>
<script src="http://img.mabach.cn/axios.js"></script>

<script th:inline="javascript">
  var app= new Vue({
    el:"#app",
    data:{
      mobile:"",
      password:"",
      code:"",
      from:[[${from}]],
      tomobile: "/api-oauth/toLogin/mobile?from="+[[${from}]],
      toregister: "/api-portal/portal/register?from="+[[${from}]],
      toQQLogin : "/api-oauth//toQQLogin?from-"+[[${from}]],


    },
    methods:{






      login (){
        // var fromUrl=this.from;
        // alert(this.from);
        axios.post(`/api-oauth/login?username=${this.username}&password=${this.password}&code=${this.code}`).then(response => {

          if (response.data.flag){
          window.location=this.from;
        }else {
          // alert("登陆失败")
          this.$message.error(response.data.message);

        }

      });
      },

    }
  })
</script>
</body>
</html>
